package com.situ.blog.service.impl;

import com.situ.blog.dao.IBlogTypeDao;
import com.situ.blog.dao.impl.BlogTypeDaoImpl;
import com.situ.blog.pojo.BlogType;
import com.situ.blog.pojo.query.BlogTypeQuery;
import com.situ.blog.service.IBlogTypeService;
import com.situ.blog.util.PageRusult;

import java.util.List;

public class BlogTypeServiceImpl implements IBlogTypeService {
    IBlogTypeDao blogTypeDao = new BlogTypeDaoImpl();
    @Override
    public List<BlogType> selectAll() {
        List<BlogType> list = blogTypeDao.selectAll();
        return list;
    }

    @Override
    public PageRusult<BlogType> selectByPage(BlogTypeQuery blogTypeQuery) {
        //1.当前页码，每页数量，每页内容
        List<BlogType> list = blogTypeDao.selectByPage(blogTypeQuery) ;
        //2.总页数
        int totalCount = blogTypeDao.totalCount(blogTypeQuery);
        PageRusult<BlogType> pageRusult = new PageRusult(0,"",totalCount,list);
        return pageRusult;
    }

    @Override
    public void add(BlogType blogType) {
        blogTypeDao.add(blogType);
    }

    @Override
    public int deleteById(int id) {
        return blogTypeDao.deleteById(id);
    }

    @Override
    public void deleteAll(String[] ids) {
        for (String id : ids) {
            blogTypeDao.deleteById(Integer.parseInt(id));
        }
    }

    @Override
    public BlogType selectById(String id) {
        BlogType blogType = blogTypeDao.selectById(id);
        return blogType;
    }

    @Override
    public void update(BlogType blogType) {
        blogTypeDao.update(blogType);
    }
}
